'use strict'
const path = require('path')

function resolve(dir) {
  return path.join(__dirname, dir)
}

const port = process.env.port || process.env.npm_config_port || 9527 // dev port

// All configuration item explanations can be find in https://cli.vuejs.org/config/
module.exports = {
  publicPath: '/',
  outputDir: 'dist',
  assetsDir: 'static',
  lintOnSave: false, //process.env.NODE_ENV === 'development',
  productionSourceMap: false,
  devServer: {
    port: port,
    open: true,
    overlay: {
      warnings: false,
      errors: true
    },
    hot: true, //跨域代理
    headers: {
      'Access-Control-Allow-Origin': '*',
      'Access-Control-Allow-Credentials': 'true'
    },
    host: '0.0.0.0',
    proxy: {
      '/dev-api': {
        target: 'http://localhost:8080',
        changeOrigin: true, 
        ws: true,
        secure: false,
        pathRewrite: {
          '^/dev-api': '' 
        }
      }
    },
    //before: require('./mock/mock-server.js')
  },
  configureWebpack: {
    // provide the app's title in webpack's name field, so that
    // it can be accessed in index.html to inject the correct title.
    name: 'SpringBootSSM',
    resolve: {
      alias: {
        '@': resolve('src')
      }
    }
  }
}
